<template>
  <div>
    <h2 class="title">热门游记与话题</h2>
    <div class="container hotthread">
      <div class="slider">
        <el-carousel indicator-position="outside" :autoplay="false" arrow="never" height="650px">
          <el-carousel-item v-for="(item, index) in travelList" :key="index">
            <ul class="list">
              <li v-for="e in item" :key="e.id">
                <div class="thread">
                  <div class="pic">
                    <img width="275" height="185" :src="e.pic" lazy="loaded">
                    <div class="like total_replies">
                      <!-- <i class="iconfont icon-xinxi"></i> -->
                      <i class="iconfont-home el-icon-chat-dot-square"></i>
                      <span>{{ e.total_replies }}</span>
                    </div>
                  </div>
                  <div class="inner">
                    <div class="info clearfix">
                      <span class="avatar">
                        <img :src="e.auth.avatar" lazy="loaded">
                      </span>
                      <span class="txt">{{ e.username }}</span>
                    </div>
                    <div class="caption">{{ e.subject }}</div>
                  </div>
                </div>
              </li>
            </ul>
          </el-carousel-item>
        </el-carousel>
      </div>
      <div class="more">
        <a href="javascript:void(0);" target="_blank">查看更多游记</a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeTravel',
  data() {
    return {
      travelList: []
    }
  },
  mounted() {
    this.getHotTravel()
  },
  methods: {
    async getHotTravel() {
      const res = await this.$api.getHotTravel()
      console.log("热门游记", res)
      this.travelList = res.data
    }
  }

}
</script>

<style scoped>
.container {

  position: relative;
  padding: 20px 0;
  width: 1160px;
  /* 固定宽度 */
  margin: 0 auto;

  .title {
    position: relative;
    height: 74px;
    color: #636363;
    text-align: center;
    font: 36px / 74px Hiragino Sans GB, Microsoft YaHei, SimHei, SimSun, sans-serif;
  }

  .hotthread {
    height: 750px;
  }

  .more {
    margin-top: 30px;
    text-align: center;

    a {
      display: inline-block;
      box-sizing: border-box;
      border: 1px solid #ececec;
      border-radius: 3px;
      width: 220px;
      height: 50px;
      vertical-align: top;
      background: #fff;
      font: 20px / 50px Hiragino Sans GB, Microsoft YaHei, SimHei, SimSun, sans-serif;
      color: #636363;
      transition: all .2s ease-in-out;
      text-decoration: none;
      text-align: center;
    }

    a:hover {
      background-color: #f5f5f5;
      border-color: #bbb;
      color: #333;
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    }
  }
}

.slider {
  .list {
    margin-left: -20px;

    li {
      float: left;
      margin-top: 20px;
      margin-left: 20px;
      width: 275px;
      height: 290px;
      background: #fff;

      .thread {
        position: relative;
        width: 275px;
        height: 185px;

        .pic {
          position: relative;
          width: 275px;
          height: 185px;
          overflow: hidden;

          img {
            display: block;
            width: 100%;
            height: 100%;
            transition: all 1.2s ease;
          }
        }

        .like {
          position: absolute;
          right: 10px;
          bottom: 4px;
          color: #fff;
          text-shadow: 0 0 2px rgba(0, 0, 0, .4);
          font-size: 14px;

          .iconfont-home {
            margin-right: 4px;
            font-size: 20px;
            vertical-align: -3px;
          }
        }
      }

      .inner {
        border: 1px solid #ececec;
        border-top: 0;
        padding: 0 15px;
        height: 104px;
        position: relative;

        .info {
          position: absolute;
          z-index: 1;
          overflow: hidden;
          top: -25px;

          .avatar {
            float: left;
            padding: 4px;
            width: 48px;
            height: 48px;
            background: #fff;
            border-radius: 50%;

            img {
              vertical-align: top;
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }

          .txt {
            float: left;
            margin-top: 25px;
            margin-left: 6px;
            width: 180px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            font-size: 14px;
            color: #636363;
          }
        }

        .caption {
          position: absolute;
          bottom: 20px;
          padding-top: 12px;
          height: 48px;
          font: 700 16px / 24px Hiragino Sans GB, Microsoft YaHei, SimHei, SimSun, sans-serif;
          overflow: hidden;
        }
      }
    }

    li:hover {
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
      z-index: 1;
    }

    li:hover .pic img {
      transform: scale(1.05);
      filter: brightness(95%);
      transition: all 0.5s ease;
    }
  }
}
</style>